// packageA/pages/bisai/bisai.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    appurl: app.apiurl,
    apiimg: app.apiimg,
    baoming3:false,
    baoming4:false,
    array: ['请选择', '男', '女'],
    index: 0,
  },
  z_open2(){
    this.setData({
      baoming3:true
    })
  },
  z_open3(){
    this.setData({
      baoming4:true
    })
  },
  z_close(){
    this.setData({
      baoming3:false,
      baoming4:false
    })
  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.currentTarget.dataset.index)
    this.setData({
      index: e.currentTarget.dataset.index
    })
  },
  z_baoming1(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
      "other_sex":_this.data.array[_this.data.index],
      "type":"2"
    }
    wx.request({
      url: app.apiurl + 'api/compete/khBm',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        })
         _this.z_close()
      }
    })
  },
  z_baoming2(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/compete/khQxBm',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        })
        _this.z_close()
      }
    })
  },
  z_baoming3(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
      "other_sex":_this.data.array[_this.data.index],
      "type":"1"
    }
    wx.request({
      url: app.apiurl + 'api/compete/khBm',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        })
         _this.z_close()
      }
    })
  },
  z_baoming4(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token")
    }
    wx.request({
      url: app.apiurl + 'api/compete/xyTzBm',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        })
         _this.z_close()
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})